﻿using Microsoft.SharePoint;

namespace SharePoint.Tests
{
  public class Disposal
  {
    public void need_dispose_created_SPSite_or_SPWeb_objects()
    {
      SPSite site1 = new SPSite("http://site");
      var title = site1.RootWeb.Title;
    }

    public void dispose_created_SPSite_or_SPWeb_objects()
    {
      SPSite site2 = new SPSite("http://site");
      var title = site2.RootWeb.Title;
      site2.Close();
    }

    public void using_created_SPSite_or_SPWeb_objects()
    {
      using (SPSite site3 = new SPSite("http://site"))
      {
        var title = site3.RootWeb.Title;
      }
    }
  }
}
